package com.jlpay.openapi.demo.ledger.balancesplit;

import com.jlpay.open.jlpay.sdk.java.model.ledger.request.BalanceRefundRequest;
import com.jlpay.open.jlpay.sdk.java.model.ledger.response.BalanceRefundResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/8/30
 **/
public class BalanceRefundService {

    private static final Logger LOGGER = LoggerFactory.getLogger(BalanceRefundService.class);

    public static void main(String[] args) {
        BalanceRefundRequest balanceRefundRequest = buildBalanceRefundRequest();
        BalanceRefundResponse balanceRefundResponse = JlpayOpenApiService.openMerchService()
                .post(balanceRefundRequest, BalanceRefundResponse.class);
        LOGGER.info("余额分账回退请求响应:{}", JsonUtils.toString(balanceRefundResponse));
    }

    private static BalanceRefundRequest buildBalanceRefundRequest() {
        BalanceRefundRequest balanceRefundRequest = new BalanceRefundRequest();
        balanceRefundRequest.setOrgCode("50720711");
        balanceRefundRequest.setMchId("849581183510017");
        balanceRefundRequest.setOutOrderNo("045e1314f7784f46bf9d590dc65c7");
        balanceRefundRequest.setOutReturnNo("12e3045e13146bf9d590d12c65c11");
        balanceRefundRequest.setRevMchId("849584307420004");
        balanceRefundRequest.setAmount(100);
        balanceRefundRequest.setDescription("分账退回");
        return balanceRefundRequest;
    }
}
